﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Education;
using HumanResources;

namespace ConsoleApplication
{
    class MyClass
    {
        public string Name { get; set; }
        public int? Value { get; set; }
        public override string ToString()
        {
            return Name;
        }
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }
            else
            {
                //MyClass o = (MyClass)obj;
                MyClass o = obj as MyClass;
                if (o == null)
                {
                    return false;
                }
                else
                {
                    return o.Name == this.Name && o.Value == this.Value;
                }
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            InheritanceTest();

            var obj1 = new MyClass();
            var obj2 = new MyClass();
            Console.WriteLine(obj1.GetHashCode());
            Console.WriteLine(obj2.GetHashCode());

            string s1 = "hello";
            string s2 = "h";
            s2 += "ello";

            Console.WriteLine(s1 + " " + s2);
            Console.WriteLine((object)s1 == (object)s2);
            Console.WriteLine(Object.ReferenceEquals(s1, s2));
            Console.WriteLine(s1.GetHashCode() == s2.GetHashCode());
            Console.WriteLine(s1 == s2);
            //TestEduation();
            //int? x = null;
            //Nullable<int> x = null;
            //TestNull(1);
            //Console.WriteLine(x);
            Console.ReadKey();

        }

        private static void InheritanceTest()
        {
            
        }

        private static void TestNull(int? x)
        {
            string s = (x == null) ? "Null" : x.ToString();
            int y = x ?? 0;

            
            // x == null ? 0 : x;
            Console.WriteLine(s);
            Console.WriteLine(y);

            int z = 1;

            unsafe
            {
                int* p = &z;
                Console.WriteLine((int)p);
                
            }
        }

        private static void TestEduation()
        {
            Address address = new Address("Yerevan", "Teryan", "5/1");

            University university = new University()
            {
                Name = "YSU",
                Address = new Address("Yerevan", "Alex Amnoukyan", "1"),
                Faculties = new List<Faculty>() 
                {
                    new Faculty("Mathematics", "001"),
                    new Faculty("Physics", "002"),
                    new Faculty("Aplied Mathematics", "003")
                }
            };

            List<Student> students = new List<Student>();
            students.Add(new Student("John Smith", address, university, university.Faculties[1]));
            students.Add(new Student("Jane Doe", address, university, university.Faculties[3]));

            foreach (var student in students)
            {
                Console.WriteLine(student);
            }
        }
    }
}
